//package com.chance.cc.crawler.development.bootstrap.xiaohongshu;
//
//import org.apache.commons.lang3.StringUtils;
//
//import javax.crypto.BadPaddingException;
//import javax.crypto.Cipher;
//import javax.crypto.IllegalBlockSizeException;
//import javax.crypto.NoSuchPaddingException;
//import java.io.ByteArrayInputStream;
//import java.net.URLDecoder;
//import java.net.URLEncoder;
//import java.security.InvalidKeyException;
//import java.security.NoSuchAlgorithmException;
//import java.security.PublicKey;
//import java.security.cert.CertificateException;
//import java.security.cert.CertificateFactory;
//import java.security.cert.X509Certificate;
//import java.util.Base64;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.Random;
//
///**
// * @author bx
// * @date 2021/11/3 0003 11:14
// */
//public class XHSSMParam {
//
//    public static String a(int i2) {
//        char[] cArr = new char[i2];
//        Random random = new Random();
//        for (int i3 = 0; i3 < i2; i3++) {
//            cArr[i3] = (char) (random.nextInt(26) + 97);
//        }
//        return new String(cArr);
//    }
//
//    public static boolean a(String str) {
//        if (str == null) {
//            return true;
//        }
//        return str.isEmpty();
//    }
//
//
//    private static byte[] a1(byte[] bArr) {
//        byte[] bArr2 = new byte[bArr.length];
//        for (int i2 = 0; i2 < bArr.length; i2++) {
//            bArr2[i2] = (byte) (~bArr[i2]);
//        }
//        return bArr2;
//    }
//
//    public static String b1(String str) {
//        return new String(a1(c(str)));
//    }
//
//    private static byte[] c(String str) {
//        byte[] bytes = str.getBytes();
//        int length = bytes.length;
//        byte[] bArr = new byte[(length / 2)];
//        for (int i2 = 0; i2 < length; i2 += 2) {
//            bArr[i2 / 2] = (byte) Integer.parseInt(new String(bytes, i2, 2), 16);
//        }
//        return bArr;
//    }
//
//    public void encryptParams() throws CertificateException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
//
//
//
//    }
//
//    private String genCA(String url) throws CertificateException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
//        int indexOf;
//        int i2 = 0;
//
//        int indexOf2 = url.indexOf("?");
//        if (indexOf2 == -1) {
//            return null;
//        }
//        boolean z = false;
//        String substring = url.substring(0, indexOf2);
//        Map<String,String> hashMap = new HashMap<>();
//        if (StringUtils.isNotBlank(url) || (indexOf = url.indexOf("?")) == -1 || (i2 = indexOf + 1) == url.length()) {
//            String[] split = url.substring(i2).split("&");
//            if (split.length != 0) {
//                for (String str2 : split) {
//                    String[] split2 = str2.split("=", 2);
//                    if (split2.length == 2) {
//                        hashMap.put(split2[0], da(split2[1]));
//                    }
//                }
//            }
//        }
//        String str3 = hashMap.remove("organization");
//        if (StringUtils.isBlank(substring)|| StringUtils.isBlank(str3)) {
//            return null;
//        }
//        String b2 = db(hashMap);
//        String a2 = a(16);
//        byte[] bytes = a2.getBytes();
//
//        PublicKey publicKey = ((X509Certificate) CertificateFactory.getInstance("X.509").
//                generateCertificate(new ByteArrayInputStream(
//                        Base64.getDecoder().decode("MIIDOzCCAiOgAwIBAgIBMDANBgkqhkiG9w0BAQUFADA4MQswCQYDVQQGEwJDTjENMAsGA1UECwwEQ05DQjEaMBgGA1UEAwwRZS5iYW5rLmVjaXRpYy5jb20wHhcNMTgwMjExMDg0NTIyWhcNMzgwMjA2MDg0NTIyWjA4MQswCQYDVQQGEwJDTjENMAsGA1UECwwEQ05DQjEaMBgGA1UEAwwRZS5iYW5rLmVjaXRpYy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCkF+2AicVKj7SaHw3dbJt3i6fkL1WfLw1WRqe8r8Cc7qJOshaqNvCzW1qRX6E5H/umtl1Uj99V07uewUFk96xY/+s/GuBnbGoSrcu3OAHDgEGuY5atZo+umIk7LufAif2VUcNGY3nWxGcig20ExO/6nAf/G3Xxo4QL8fBdPG/prOXxSvtJiPls1Qg9zzSgAH+HMCAINMsuJmzDQiTt6Me8k7YHts+jWQF7KF25plITcW1Qmy3Aw8qYjVhbHn8KTAEeuQhmM5RS6KP1Hu71q4DYOWcx44QThSbiAYwG1JQBBwM8XnBfVYMpr6Qi0owibNYoZ/S6xwfRFGB0W1HeG9WfAgMBAAGjUDBOMB0GA1UdDgQWBBT0iLEXY9HIKNy5DG4d72l+R7Nf1zAfBgNVHSMEGDAWgBT0iLEXY9HIKNy5DG4d72l+R7Nf1zAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQB5MWz1RGFG537rJCtHp+LqxR9iJSFsHiW3ZoLIAeyD0oJ69RcL2gE/TNWmE9zYUkd9TdNtXqxlNPpj1P1/+x781neWnGou/n/XFS82T5S339X3DIjHc/IqOzwnxEOKH2V0NmK9iKgx6H05Q9MMvUXFsL3QK2hDMAVY28roRiC4S1yfJJaA08DfvXZf6cVx1xfWl+ks57+3knkoWap1rjwh1RdGk5ChPbzD0AnAcWTMWRCbjuJnttlmWZnI1I6mhcQUKUEMoj8sR8m11YJ5woscYPsIle/rJOOosuMghczD1vRcg3eLUaWn1A5rsBa82RyxhiuYocEQVX59Hy6v3npT")))).getPublicKey();
//
//        Cipher instance = Cipher.getInstance("RSA/ECB/PKCS1Padding");
//        instance.init(1, publicKey);
//
//        String pri = Base64.getEncoder().encodeToString(instance.doFinal(bytes));
//        System.out.println(pri);
//
//        String ca = a(a2,b2)
//
//    }
//
//    public static String da(String str) {
//        if (!(str == null || str.length() == 0)) {
//            try {
//                return URLDecoder.decode(str, "UTF-8");
//            } catch (Exception unused) {
//            }
//        }
//        return "";
//    }
//
//    public static String db(Map<String, String> map) {
//        if (map == null || map.size() == 0) {
//            return "";
//        }
//        int i2 = 0;
//        StringBuilder sb = new StringBuilder();
//        for (String str : map.keySet()) {
//            sb.append(str);
//            sb.append("=");
//            sb.append(b(map.get(str)));
//            i2++;
//            if (i2 < map.size()) {
//                sb.append("&");
//            }
//        }
//        return sb.toString();
//    }
//
//    private static String b(String str) {
//        if (!(str == null || str.length() == 0)) {
//            try {
//                return URLEncoder.encode(str, "UTF-8");
//            } catch (Exception unused) {
//            }
//        }
//        return "";
//    }
//
//
//    public static void main(String[] args) {
//        System.out.println(b1("9c909b9a"));
//        System.out.println(b1("8f8d96"));
//        System.out.println(b1("9c9e"));
//        System.out.println(b1("8b96929a8c8b9e928f"));
//        System.out.println(b1("929bca"));
//        System.out.println(b1("c0908d989e9196859e8b969091c2"));
//        System.out.println(b1("908d989e9196859e8b969091"));
//    }
//}
